
package com.market.web.action;

import java.util.List;

import com.market.bean.Customer;
import com.market.web.form.CustomerForm;
import com.market.web.utils.ListUtils;

public class AdminFavourSearchAction extends BaseAction2
{
    public String execute() throws Exception
    {
        String search = getRequest().getParameter("search");
        if (!"product".equals(search) && !"message".equals(search))
        {
            return INPUT;
            //return mapping.getInputForward();
        }
        List list = null;
        if ("product".equals(search))
        {
            String proid = getRequest().getParameter("productid");
            String[] sId = proid.split(",");
            Long[] id = new Long[sId.length];
            for (int i = 0; i < sId.length; i++)
            {
                try
                {
                    id[i] = Long.valueOf(sId[i]);
                }
                catch (Exception e)
                {
                    // TODO: handle exception
                }
            }
            list = getCustomerService().findByProductId(id);

        }
        if ("message".equals(search))
        {
            String type = getRequest().getParameter("type");
            String category = getRequest().getParameter("category");
            list = getCustomerService().findByMessage(type, category);
        }
        getRequest().getSession().setAttribute("customer", ListUtils.convert(list, Customer.class, CustomerForm.class));
        
        return SUCCESS;
        //return mapping.findForward("favourSend2");
    }
}
